package com.aki.ai_property.service.impl;

import com.aki.ai_property.dao.FireDao;
import com.aki.ai_property.entity.Fire;
import com.aki.ai_property.service.intf.FireService;
import com.aki.ai_property.vo.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aki.ai_property.vo.Result;


/**
 * Author:WuChuangChuang
 * Date:2022/8/27 19:30
 */
@Service
public class FireServiceImpl implements FireService {
    @Autowired
    private FireDao dao;

    /** 新增 */
    @Override
    public Result save(Fire fire) {
        if (dao.save(fire) >0){
            return Result.ok("新增成功");
        }
        return Result.fail("新增失败");
    }

    /** 修改 */
    @Override
    public Result update(Fire fire) {
        if(dao.update(fire) >0){
            return Result.ok("修改成功");
        }
        return Result.fail("修改失败");
    }

    /** 删除 */
    @Override
    public Result delete(int id) {
        if (dao.delete(id) >0){
            return Result.ok("删除成功");
        }
        return Result.fail("删除成功");
    }

    /** 查询 */
    @Override
    public PageBean all(String name,int page,int limit) {
        return PageBean.ok(dao.selectCount(name),dao.selectPage(name,page,limit));
    }

    @Override
    public Result delIds(int[] ids) {
        if (dao.delByIds(ids)>0){
            return Result.ok();
        }else {
            return Result.fail();
        }
    }

}
